package com.qq.first_project.util;


import java.io.File;
import java.io.FileOutputStream;

/**
 * @Author: Qiu
 * @Data: 2022-04-06
 * 图片工具类
 */
public class PictureUtils {

    public static String uploadPicture(byte[] file, String path, String name) throws Exception {
        File targetFile = new File(path);
        //父目录不存在则创建
        if(!targetFile.exists()){
            targetFile.mkdirs();
        }
        //使用UUID重命名以免文件名重复
        String dest = path + name;
        FileOutputStream out = new FileOutputStream(dest);
        out.write(file);
        out.flush();
        out.close();
        return dest;
    }

}